<template>
  <dialog-editor ref="dialog"></dialog-editor>
</template>

<script>
import DialogEditor from '@/components/DialogEditor'
import dialogMixins from '@/utils/commonDialogMixins'

export default {
  mixins: [dialogMixins],
  components: {DialogEditor},
  data() {
    return {
      dataFormConfig: {
        id: {
          hidden: true
        },
        trayInfoId: {
          label: '托盘',
          type: 'list',
          placeholder: '请选择托盘',
          list: []
        },
        trayNumber: {
          label: '拖盘数量',
          type: 'number',
          max: 1000,
          default: 0
        },
        dayTime: {
          label: '日期',
          type: 'date',
          placeholder: '请选择日期'
        },
        status: {
          label: '状态',
          type: 'switch',
          activeValue: 1,
          inactiveValue: 0,
          default: 1
        }
      }
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.initTrayList()

      this.$refs.dialog.initDialog({
        dataForm: this.dataForm,
        config: this.dataFormConfig,
        dataRule: this.getNeedDataRule('trayInfoId','dayTime', 'status'),
        initApi: 'trayApi/trayLeaveInfo',
        saveApi: 'trayApi/saveTrayLeave',
        updateApi: 'trayApi/updateTrayLeave',
        objectName: 'trayLeave'
      })
    }
  }
}
</script>
